<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function* generator_test(){
            console.log('zihao');
            yield '子豪';
            console.log('暂停之后可以继续执行！！');
            yield '学晨';
            console.log('继续');
            yield '洋洋'
        }
        let result = generator_test();
        console.log(result);
        console.log(result.next());
        console.log(result.next());
        console.log(result.next());
        console.log(result.next());

        let obj  = {};
        obj[Symbol.iterator] = function* (){
            yield 'zihao';
            yield 'xuechen';
            yield 'yangynag'
        }

        for( let i of obj){
            console.log(i);
        }
        console.log(obj);
    </script>
</body>
</html>